<?php
session_start ();
error_reporting(0);
include '_admin/include/sql.php';
$code = $_GET ["code"];
$id = $_GET ["id"];
$query = "SELECT * FROM activate WHERE member_id = $id AND activate_code = '$code'";
$rs1 = mysql_query($query);
if($rs1 != null && mysql_num_rows($rs1) > 0){
	// Update new status for that user
	$query = "UPDATE member SET is_activated = 1 WHERE id = $id";
	mysql_query($query);
	// Ok, now delete that record in activate table.
	$query = "DELETE FROM activate WHERE member_id = $id";
	mysql_query($query);
	$_SESSION["is_activated"] = 1;
	header("Location: index.php");
}
else{
	header("Location: index.php?msg=wrong-activate-code");
}
?>